package com.baomidou.springboot.controller;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.springboot.dto.CommonResult;
import com.baomidou.springboot.dto.QueryParam;
import com.baomidou.springboot.service.impl.BaseService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;



@RestController
public abstract class BaseController <T > {

    @Autowired
    private BaseService <T> baseService;  
    
    public abstract BaseService<T> getBaseService() ;
    @ResponseBody
    @RequestMapping(value = "/listpages")
    public Object listByPage(T t,
                       @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                       @RequestParam(name = "queryParams", required = false)  List <QueryParam> queryParams
                       ) {
                        QueryWrapper<T> queryWrapper = new QueryWrapper<T>();
                      IPage<T> p=  baseService.selectPageByCondition(new Page<T>(pageNum,pageSize), queryWrapper);
                      return new CommonResult().pageSuccess(p);
    }

  
}

